package com.soonfor.evaluate.bean;

import com.soonfor.evaluate.tools.CommonUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：DC-DingYG on 2018-11-16 9:28
 * 邮箱：dingyg012655@126.com
 * 保存 评价客户
 */
public class EvalCustSaveBean {
    private String fappraiseoriid;//评价来源id
    private String fappraiseoritype;//评价来源类型
    private String getdatatype;//取数类型 0.客户评价，1.评价客户
    private String fallhighappraiseresult;//整体评价结果
    private String fappraisecontent;//评价内容
    private List<ResSortItemDto> appraisestars;//星级评价对象
    private List<UploadImageBean> appraiseimgs;//评价图片对象
    public String getFappraiseoriid() {
        return CommonUtils.formatStr(fappraiseoriid);
    }

    public void setFappraiseoriid(String fappraiseoriid) {
        this.fappraiseoriid = fappraiseoriid;
    }

    public String getFappraiseoritype() {
        return CommonUtils.formatStr(fappraiseoritype);
    }

    public void setFappraiseoritype(String fappraiseoritype) {
        this.fappraiseoritype = fappraiseoritype;
    }

    public String getGetdatatype() {
        return CommonUtils.formatStr(getdatatype);
    }

    public void setGetdatatype(String getdatatype) {
        this.getdatatype = getdatatype;
    }

    public String getFallhighappraiseresult() {
        return CommonUtils.formatStr(fallhighappraiseresult);
    }

    public void setFallhighappraiseresult(String fallhighappraiseresult) {
        this.fallhighappraiseresult = fallhighappraiseresult;
    }

    public String getFappraisecontent() {
        return CommonUtils.formatStr(fappraisecontent);
    }

    public void setFappraisecontent(String fappraisecontent) {
        this.fappraisecontent = fappraisecontent;
    }

    public List<ResSortItemDto> getApprasestars() {
        return appraisestars == null ? new ArrayList<ResSortItemDto>() : appraisestars;
    }

    public void setApprasestars(List<ResSortItemDto> apprasestars) {
        this.appraisestars = apprasestars;
    }

    public List<UploadImageBean> getAppraiseimgs() {
        return appraiseimgs == null ? new ArrayList<UploadImageBean>() : appraiseimgs;
    }

    public void setAppraiseimgs(List<UploadImageBean> appraiseimgs) {
        this.appraiseimgs = appraiseimgs;
    }

    public static class ResSortItemDto {
        private String fappraiseitemid;//评价分类id
        private String fpoint;//得分

        public String getFappraiseitemid() {
            return fappraiseitemid;
        }

        public void setFappraiseitemid(String fappraiseitemid) {
            this.fappraiseitemid = fappraiseitemid;
        }

        public String getFpoint() {
            return fpoint;
        }

        public void setFpoint(String fpoint) {
            this.fpoint = fpoint;
        }
    }

    public String getJsonStrFromReSortItemDtos(){
        final JSONArray ja = new JSONArray();
        try {
            List<ResSortItemDto> resSortItemDtoList = getApprasestars();
            for (int i = 0; i < resSortItemDtoList.size(); i++) {
                ResSortItemDto bean = resSortItemDtoList.get(i);
                JSONObject jo = new JSONObject();
                try {
                    jo.put("fappraiseitemid", bean.getFappraiseitemid());
                    jo.put("fpoint",bean.getFpoint());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                ja.put(i, jo);
            }
        } catch (Exception e) {}
        return ja.toString();
    }
}
